#ifndef __SOFT_I2C_H__
#define __SOFT_I2C_H__

#include "main.h"

// 将SDA设置为高电平（释放）
#define i2c_sda_high()  HAL_GPIO_WritePin(CH8_GPIO_Port, CH8_Pin, GPIO_PIN_SET)
// 将SDA设置为开漏输出
#define i2c_sda_low()   HAL_GPIO_WritePin(CH8_GPIO_Port, CH8_Pin, GPIO_PIN_RESET)
// 将SCL设置为高电平
#define i2c_scl_high()  HAL_GPIO_WritePin(CH7_GPIO_Port, CH7_Pin, GPIO_PIN_SET)
// 将SCL设置为低电平
#define i2c_scl_low()   HAL_GPIO_WritePin(CH7_GPIO_Port, CH7_Pin, GPIO_PIN_RESET)
// 读取sda电平
#define i2c_sda_read()  HAL_GPIO_ReadPin(CH8_GPIO_Port, CH8_Pin)

void soft_i2c_init(void);
uint8_t soft_i2c_write_register(uint8_t device_address, uint8_t register_address, uint8_t* data, int len);
uint8_t soft_i2c_read_register(uint8_t device_address, uint8_t register_address, uint8_t* data, int len);


#endif /* __SOFT_I2C_H__ */
